package com.maxis;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStream;

import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;

public class CSVFactory {
	protected static String message;
	private static final String CONFIG_FILE = "/maxis.properties";
	private static final java.util.Properties configProp = new java.util.Properties();
	
	public static String getMessage(){
		return "[CSVFactory] " + CSVFactory.message;
	}
	
	public static CSVReader getReader(String file_path, char sep){
		try {
			CSVReader reader = new CSVReader(new FileReader(file_path), sep);
			
			return reader;
			 
		} catch (Exception e){
			CSVFactory.message = e.getMessage();
			return null;
		}
	}
	
	public static CSVWriter getWriter(String file_path, char sep){
		try {
			CSVWriter writer = new CSVWriter(new FileWriter(file_path), sep, CSVWriter.NO_QUOTE_CHARACTER);
			
			return writer;
			
		} catch (Exception e){
			CSVFactory.message = e.getMessage();
			return null;
		}
	}
	
}
